define(['../../../../js/lib/other/sweet-alert'],function() {
    return ['$scope','$location', '$interval','$timeout','$routeParams','bizProxy', function($scope,$location,$interval,$timeout,$routeParams,bizProxy) {
    	$scope.$emit("top-show",'true');//顶部显示
    	$scope.$emit('menuTypeLight','loan'); 	//控制底部menu高亮
    	$scope.$emit('bub-menu','true'); 	//隐藏底部menu
    	$scope.$emit('flag-tag','58'); 	//显示底部文字
    	
    	var questionSurveyList = [
    	                             {
    	                                 "name": "您的年龄",
    	                                 "index": 0,
    	                                 "info": [
    	                                     {
    	                                         "name": "25-45周岁",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "45-60周岁",
    	                                         "val": 3,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "25周岁以下或60周岁以上",
    	                                         "val": 1,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "执业年限",
    	                                 "index": 1,
    	                                 "info": [
    	                                     {
    	                                         "name": "7年以上",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "3-7年",
    	                                         "val": 3,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "0-3年",
    	                                         "val": 1,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "执业区域",
    	                                 "index": 2,
    	                                 "info": [
    	                                     {
    	                                         "name": "一线城市或长三角地区",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "二线或省会城市",
    	                                         "val": 3,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "其他",
    	                                         "val": 1,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "个人身份",
    	                                 "index": 3,
    	                                 "info": [
    	                                     {
    	                                         "name": "合伙人律师",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "执业律师",
    	                                         "val": 3,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "是否有行业协会不良记录",
    	                                 "index": 4,
    	                                 "info": [
    	                                     {
    	                                         "name": "是",
    	                                         "val": -30,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "否",
    	                                         "val": 0,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "案由 ",
    	                                 "index": 5,
    	                                 "info": [
    	                                     {
    	                                         "name": "合同纠纷",
    	                                         "val": 10,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "股权纠纷",
    	                                         "val": 8,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "侵权赔偿案件",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "人身损害及其他",
    	                                         "val": 3,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "证据充分程度",
    	                                 "index": 6,
    	                                 "info": [
    	                                     {
    	                                         "name": "证据充足且合法",
    	                                         "val": 15,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "有证据但不完整",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "无证据或证据不能印证诉求",
    	                                         "val": -30,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "案件管辖法院",
    	                                 "index": 7,
    	                                 "info": [
    	                                     {
    	                                         "name": "一线城市或长三角地区",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "二线或省会城市",
    	                                         "val": 3,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "其他 ",
    	                                         "val": 1,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "申请人是否曾代理同类案件",
    	                                 "index": 8,
    	                                 "info": [
    	                                     {
    	                                         "name": "是",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "否",
    	                                         "val": 0,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "申请人是否有同类胜诉案件",
    	                                 "index": 9,
    	                                 "info": [
    	                                     {
    	                                         "name": "是",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "否",
    	                                         "val": 0,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "被告财产状况",
    	                                 "index": 10,
    	                                 "info": [
    	                                     {
    	                                         "name": "有不动产、存款、证券、股权、应收账款等",
    	                                         "val": 15,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "有知识产权或其他财产权利",
    	                                         "val": 10,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "被告注册资本（企业）",
    	                                 "index": 11,
    	                                 "info": [
    	                                     {
    	                                         "name": "注册资本：100万及以上",
    	                                         "val": 10,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "10万及以上",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "10万以下",
    	                                         "val": 10,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "被告有涉诉、被执行案件",
    	                                 "index": 12,
    	                                 "info": [
    	                                     {
    	                                         "name": "无诉讼无执行",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "有诉讼无执行",
    	                                         "val": -5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "有未了结被执行案件",
    	                                         "val": -20,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "被告公告送达或提起管辖权异议",
    	                                         "val": -10,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "其他",
    	                                 "index": 13,
    	                                 "info": [
    	                                     {
    	                                         "name": "被告已列入经营异常名录",
    	                                         "val": -10,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "被告征信有三次或三次以上记录",
    	                                         "val": -10,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "被告被列入失信被执行人",
    	                                         "val": -10,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "以上均无",
    	                                         "val": 0,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             },
    	                             {
    	                                 "name": "赢火虫投入成本及预期收益",
    	                                 "index": 14,
    	                                 "info": [
    	                                     {
    	                                         "name": "预期收益大于投入成本的2倍",
    	                                         "val": 10,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "预期收益在投入成本的1.5倍至2倍间",
    	                                         "val": 5,
    	                                         "slt": false
    	                                     },
    	                                     {
    	                                         "name": "收入预期低于投入成本的1.5倍",
    	                                         "val": 0,
    	                                         "slt": false
    	                                     }
    	                                 ]
    	                             }
    	                             
    	                         ];
    	$scope.questionSurveyList = questionSurveyList;
    	
    	//点击选择答案
    	$scope.selectQuesition = function(num,index){
    		var partList = questionSurveyList[num].info;
    		partList.forEach(function(e){
    			e.slt = false;
    		});
    		partList[index].slt = true;
    		$scope.questionSurveyList = questionSurveyList;
    	}
    	
    	//点击提交
    	$scope.subExamPaper = function(){
    		 var sweetData = {
   					title : "是否确认提交？",
   					text : "",
   					type : "",
   					showCancelButton : true,
   					closeOnConfirm : false
   			};
       		sweetAlert(sweetData,function(){
       			$timeout(function(){
       					//计算分数
       					calculateScore();
       			},500);
       		},function(){return;});
       			
       		var headerInfo = {},bizInfo = {};
       			 	 
    	}
    	
    	function calculateScore(){
    		var score = 0;
    		for(var i=0;i<questionSurveyList.length;i++){
    			var tempList = questionSurveyList[i].info;
    			for(var j=0;j<tempList.length;j++){
    				if(tempList[j].slt){
    					score += tempList[j].val;
    				}
    			}
    		}
    		checkAnswerData(score);
    		
    	}
    	
    	//处理题目和答案
    	function checkAnswerData(score){
    		var answerArray = new Array();
    		for(var i=0;i<questionSurveyList.length;i++){
    			var tempList = questionSurveyList[i].info;
    			var tempData = {"title":questionSurveyList[i].name};
    			for(var j=0;j<tempList.length;j++){
    				if(tempList[j].slt){
    					tempData.answer = tempList[j].name;
    					break;
    				}else{
    					tempData.answer = "";
    				}
    			}
    			answerArray.push(tempData);
    		}
    		
    		//transData.score = score;
    		transData.rcDetail = JSON.stringify(answerArray);
    		subSurveyData(score);
    		//$scope.$emit("goNext","/");
			//$location.path("/").replace();//想改变当前 URL 而不创建新的历史记录的话
    	}
    	
    	
    	
    	function subSurveyData(score){
	    	var headerInfo = {},bizInfo = {};
	    	headerInfo.pageNum = '';
	        headerInfo.pageSize = '';
	        headerInfo.sessionId = transData.sessionId;
	        
	        bizInfo.applyId = $routeParams.flag;
	        bizInfo.rcScore = score;
	        bizInfo.rcDetail = transData.rcDetail;
	        
	        console.log(bizInfo);
	        $scope.$emit("loadingChange",true);
	        bizProxy.queryProxyBizData("vcAgentRcRecord",headerInfo,bizInfo,
    				function(tempData){//SUCCESS
    				   $scope.$emit("loadingChange",false);
		        		if(score >= 60){
			    		    $timeout(function(){
									FIREFLY("提交成功,请等待平台审核！", "我方会在2个工作日内审核完毕","",function(){
									    $timeout(function(){
									       $scope.$emit("goNext","/");
									       $location.path("/").replace();//想改变当前 URL 而不创建新的历史记录的话
							            },0);
									});
							},100);	
			    		}else{
			    		     FIREFLY("对不起，您未达到\"风险投\"申请的标准！", "","",function(){
							   $timeout(function(){
			            		//	history.back();
							   },0);
						     }); 
			    	    }
						
					   console.log(tempData);
		    		},function(data) {
						if (data != "") {//FAIL
							$scope.$emit("loadingChange", false);
							if (data.errorCode == ERROR_CODE.noLogin) {
								FIREFLY("", data.errorMsg, "", function () {
									//调用退出登录
									transData.mobileNo = "";
									transData.password = "";
									transData.sessionId = "";
									transData.userType = "";
									resultData.loginUserData = "";
									resultData.loginResultData = "";
									$timeout(function () {
										$scope.$emit("goNext", "/mine");
									}, 0);
								});
							} else {
								$scope.$emit("promptAlertMsg", data.errorMsg);
								$scope.$emit("showCollect", true);
								$timeout(function () {
									$scope.$emit("showCollect", false);
								}, transData.promptTime);
							}
						} else {
							$scope.$emit("loadingChange", false);
							$scope.$emit("promptAlertMsg", "连接超时");
							$scope.$emit("showCollect", true);
							$timeout(function () {
								$scope.$emit("showCollect", false);
							}, transData.promptTime);
						}

		    		});
          
    	}
    	
        	
        	
    $scope.$apply();
    }];
});